package com.daixiaowei;

import com.daixiaowei.service.RestaurantService;
import com.daixiaowei.repository.RestaurantRepository;
import com.daixiaowei.controller.RestaurantController;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.context.ApplicationContext;

import static org.junit.jupiter.api.Assertions.assertNotNull;

@SpringBootTest // 表示这是一个Spring Boot的集成测试
public class ApplicationContextTest {

    @Autowired
    private ApplicationContext applicationContext; // 注入Spring的应用上下文

    @Test
    public void contextLoads() {
        // 检查所有的Bean是否被正确注册

        // 检查RestaurantService是否在上下文中
        RestaurantService restaurantService = applicationContext.getBean(RestaurantService.class);
        assertNotNull(restaurantService, "RestaurantService Bean should not be null");

        // 检查RestaurantRepository是否在上下文中
        RestaurantRepository restaurantRepository = applicationContext.getBean(RestaurantRepository.class);
        assertNotNull(restaurantRepository, "RestaurantRepository Bean should not be null");

        // 检查RestaurantController是否在上下文中
        RestaurantController restaurantController = applicationContext.getBean(RestaurantController.class);
        assertNotNull(restaurantController, "RestaurantController Bean should not be null");
    }
}
